from web import models
from datetime import datetime
def createPlans():
    r'''
    生成套餐
    
    INSERT INTO web_plans VALUES (1, '个人免费版', '20g', '200mb/s', 'infinity');
    
    INSERT INTO web_plans VALUES (2, '普通畅享版', '100g', '2mb/s', '1y');
    
    INSERT INTO web_plans VALUES (3, '会员尊享版', '200g', 'infinity', '1y');
    '''
    plans = [
        {
            'plan': 1,
            'title': '个人免费版',
            'memory_size': '20g',
            'download_speed': '200kb/s',
            'valid_duration': 'infinity'
        },
        {
            'plan': 2,
            'title': '普通畅享版',
            'memory_size': '100g',
            'download_speed': '2mb/s',
            'valid_duration': '1y'
        },
        {
            'plan': 3,
            'title': '会员尊享版',
            'memory_size': '200g',
            'download_speed': 'infinity',
            'valid_duration': '1y'
        }
    ]
    for plan in plans:
        if not models.Plans.objects.filter(plan=plan['plan']).exists():
            models.Plans.objects.create(**plan)
    
    print('[' + str(datetime.now())+ '] ' + 'INFO:Successfully prepare for plans loading')